package me.zhengjie.modules.service.impl;

import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.domain.EnterpriseDic;
import me.zhengjie.modules.repository.EnterpriseDicMapper;
import me.zhengjie.modules.service.EnterpriseDicService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("EnterpriseDicService")
@RequiredArgsConstructor
public class EnterpriseDicServiceImpl implements EnterpriseDicService {

    private final EnterpriseDicMapper enterpriseDicMapper;

    @Override
    public int AddDic(EnterpriseDic dic) {
        return enterpriseDicMapper.insertDic(dic);
    }

    @Override
    public List<EnterpriseDic> findDicByPage(Map<String, Object> map) {
        return enterpriseDicMapper.selectDicForPage(map);
    }

    @Override
    public int findDicForPageByTotal(Map<String, Object> map) {
        return enterpriseDicMapper.selectDicForPageByTotal(map);
    }

    @Override
    public int removeDic(EnterpriseDic dic) {
        return enterpriseDicMapper.deleteDic(dic);
    }

    @Override
    public int editDic(EnterpriseDic dic) {
        return enterpriseDicMapper.updateDic(dic);
    }

    @Override
    public List<EnterpriseDic> findDicByType(String type) {
        return enterpriseDicMapper.selectDicByType(type);
    }

    @Override
    public int findDicByValue(String value) {
        return enterpriseDicMapper.selectDicByValue(value);
    }

    @Override
    public int relationDicAndEnter(Long enterId, Long dicId) {
        return enterpriseDicMapper.insertDicAndEnter(dicId,enterId);
    }

    @Override
    public int relieveRelationDicAndEnter(Long enterId, Long dicId) {
        return enterpriseDicMapper.deleteDicAndEnter(dicId,enterId);
    }
}
